
 <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  
    <title>组件配置化 | Here. There.</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1">
    
    <meta name="author" content="被删">
    
    <meta name="description" content="配置化思想，其实可以在很多的地方使用。很多时候，我们在设计接口、应用、数据等情况下，配置化的方式可以允许我们获得更高的自由度。这里我们简单讲讲组件的配置化吧。">
    
    
    
    
    <link rel="alternate" href="/atom.xml" title="Here. There." type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/pacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/pacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
    
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?3d902de4a19cf2bf179534ffd2dd7b7f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</head>

  <body>
    <header>
      <div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/sun.png" alt="Here. There." title="Here. There."/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="Here. There.">Here. There.</a></h1>
				<h2 class="blog-motto">Love ice cream. Love sunshine. Love life. Love the world. Love myself. Love you.</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					
						<li><a href="/">首页</a></li>
					
						<li><a href="https://github.com/godbasin/godbasin.github.io">所有文章</a></li>
					
						<li><a href="/archives">归档</a></li>
					
						<li><a href="/categories">分类</a></li>
					
						<li><a href="https://godbasin.github.io/front-end-playground">前端游乐场</a></li>
					
						<li><a href="/about">关于我</a></li>
					
				</ul>
			</nav>			
</div>

    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2018/06/09/component-with-configuration/" title="组件配置化" itemprop="url">组件配置化</a>
  </h1>
  <p class="article-author">By
    
      <a href="https://godbasin.github.io" title="被删">被删</a>
    </p>
  <p class="article-time">
    <time datetime="2018-06-09T09:59:18.000Z" itemprop="datePublished">2018-06-09</time>
    更新日期:<time datetime="2018-08-18T12:58:12.093Z" itemprop="dateModified">2018-08-18</time>
    
  </p>
</header>
	<div class="article-content">
		
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#配置化思想"><span class="toc-number">1.</span> <span class="toc-text">配置化思想</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的数据"><span class="toc-number">1.1.</span> <span class="toc-text">可配置的数据</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#应用中的可配置数据"><span class="toc-number">1.1.1.</span> <span class="toc-text">应用中的可配置数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#代码中的可配置数据"><span class="toc-number">1.1.2.</span> <span class="toc-text">代码中的可配置数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#文件里的可配置数据"><span class="toc-number">1.1.3.</span> <span class="toc-text">文件里的可配置数据</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的接口"><span class="toc-number">1.2.</span> <span class="toc-text">可配置的接口</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的页面"><span class="toc-number">1.3.</span> <span class="toc-text">可配置的页面</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的应用"><span class="toc-number">1.4.</span> <span class="toc-text">可配置的应用</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#组件配置化"><span class="toc-number">2.</span> <span class="toc-text">组件配置化</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的数据-1"><span class="toc-number">2.1.</span> <span class="toc-text">可配置的数据</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的样式"><span class="toc-number">2.2.</span> <span class="toc-text">可配置的样式</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#根据子元素配置CSS"><span class="toc-number">2.2.1.</span> <span class="toc-text">根据子元素配置CSS</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#根据子-class-配置CSS"><span class="toc-number">2.2.2.</span> <span class="toc-text">根据子 class 配置CSS</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的展示"><span class="toc-number">2.3.</span> <span class="toc-text">可配置的展示</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的功能"><span class="toc-number">2.4.</span> <span class="toc-text">可配置的功能</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#结束语"><span class="toc-number">3.</span> <span class="toc-text">结束语</span></a></li></ol>
		</div>
		
		<p>配置化思想，其实可以在很多的地方使用。很多时候，我们在设计接口、应用、数据等情况下，配置化的方式可以允许我们获得更高的自由度。这里我们简单讲讲组件的配置化吧。<br><a id="more"></a></p>
<h1 id="配置化思想"><a href="#配置化思想" class="headerlink" title="配置化思想"></a>配置化思想</h1><hr>
<h2 id="可配置的数据"><a href="#可配置的数据" class="headerlink" title="可配置的数据"></a>可配置的数据</h2><p>数据的配置，或许大家会比较熟悉。像一些静态数据呀，或者说我们很多的管理端都是用来进行数据配置的。</p>
<h3 id="应用中的可配置数据"><a href="#应用中的可配置数据" class="headerlink" title="应用中的可配置数据"></a>应用中的可配置数据</h3><p>最常见的数据配置，大概是应用里面的配置，文案呀、说明等，为此我们有了运营这样的职位。常见的方式，则是搭起一整套的运营管理平台，一些简单的文字或是数据，则可以通过平台进行配置。</p>
<h3 id="代码中的可配置数据"><a href="#代码中的可配置数据" class="headerlink" title="代码中的可配置数据"></a>代码中的可配置数据</h3><p>有些时候，我们也会在代码里面放置一些可配置的数据。例如说，这个需求需要查询一周的数据，常见的做法是将天数配置为7天：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">const</span> QUERY_DAY_NUM = <span class="number">7</span>;</div></pre></td></tr></table></figure>
<p>这样，当需要在紧急情况支持其他天数（五一、国庆、过年能假期）的时候，我们就可以只需要改动这里就好啦。</p>
<h3 id="文件里的可配置数据"><a href="#文件里的可配置数据" class="headerlink" title="文件里的可配置数据"></a>文件里的可配置数据</h3><p>有些情况下，一些影响逻辑的配置数据，要是直接写到代码里，在调整的时候通常需要重新打包部署，这样情况下开销大、效率低。</p>
<p>所以在一些时候，我们会把这样的可配置数据，单独写到某个文件里维护。当需要调整的时候，只需要下发一个配置文件就好啦。</p>
<h2 id="可配置的接口"><a href="#可配置的接口" class="headerlink" title="可配置的接口"></a>可配置的接口</h2><p>关于接口的配置化，目前来说见过的不是特别多。毕竟目前来说，我们的很多数据和接口并不是简单的增删查改这样的功能，很多时候还需要在接口返回前后，做一系列的逻辑处理。</p>
<p>简单地说，很多的业务接口场景复用性不高，前后端除去协议、基础规范的定义之后，很少再能进行更深层次的抽象，导致接口配置化的改造成本较大。</p>
<p>配置化的实现有两点很重要的东西：<strong>规范</strong>和<strong>解决方案</strong>。如果说目前较好的从前端到后台的规范，可能 <a href="https://graphql.cn/" target="_blank" rel="external">GrapgQL</a> 和 Restful ，大家不熟悉的也可以去看看啦。</p>
<p>当然，或许有些团队已经实现了，也希望尽快能看到一些相关的解决方案啦。</p>
<h2 id="可配置的页面"><a href="#可配置的页面" class="headerlink" title="可配置的页面"></a>可配置的页面</h2><p>页面的配置化，可能也已经不少见了吧。像我刚出道的时候，也写过<a href="http://o907xb1mi.bkt.clouddn.com/index.html" target="_blank" rel="external">一个拖拽的 demo</a>，虽然现在光想想那时候的 jQuery 代码就惨不忍睹，不过当时还是觉得自己挺牛逼的。</p>
<p>有些时候，一些页面比较简单，里面的板块、功能比较相似，可能文案不一致、模块位置调整了、颜色改变等等。虽然说复制粘贴再改一改，很多时候也能满足要求，但是配置化的思想，就是要把重复性的工作交给机器呀。</p>
<p>这种页面的配置，基本上有两种实现方式：</p>
<ol>
<li>配置后生成静态页面的代码，直接加载生成的页面代码。</li>
<li>写通用的配置化逻辑，在加载页面的时候拉取配置数据，动态生成页面。</li>
</ol>
<p>基于 SEO 和实现复杂度各种情况，第一种方式大概是目前比较常用的，第二种的实现难度会稍微大一些，同时对于 SEO 与单页应用有着相同的困境。</p>
<p>第一种方式，很多适用于一些移动端的模版页面开发，例如简单的活动页面、商城页面等等。</p>
<p>第二种的话，更多的是一些管理平台的实现，毕竟大多数都是增删查改，形式无非列表、表单和菜单等。之前我也捣鼓过一小会的 Angular 表单、列表等配置，可以看看<a href="http://otaj284f8.bkt.clouddn.com/#/home/custom-app" target="_blank" rel="external">Angular自定义页面</a>和这个<a href="http://p2n7500x0.bkt.clouddn.com/index.html" target="_blank" rel="external">Angular2 Schema Form Exemple</a>。嗯，可能有些bug，don’t mind don’t mind~</p>
<h2 id="可配置的应用"><a href="#可配置的应用" class="headerlink" title="可配置的应用"></a>可配置的应用</h2><p>可配置的应用，大概更多地是从业务和应用设计的角度出发。当我们设计一个应用的时候，页面是活动的、可变的、可配置的，这些都是需要考虑到的地方。</p>
<p>当然，如果说涉及到代码实现的话，那大概与上面的相关。配置化的思想，其实或许不局限于代码、工程和我们的工作，甚至我们完全可以拓展至我们的生活中。</p>
<h1 id="组件配置化"><a href="#组件配置化" class="headerlink" title="组件配置化"></a>组件配置化</h1><hr>
<p>那么这里我们来讲一下简单的配置化组件的实现把。关于组件的封装，我们在<a href="https://godbasin.github.io/2018/06/02/component-with-itself/">《一个组件的自我修养》</a>一文也讲述过。</p>
<p>下面的组件，我们同样拿这样一个卡片组件来作为例子吧。</p>
<p><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/1524133892%281%29.jpg" alt="image"></p>
<h2 id="可配置的数据-1"><a href="#可配置的数据-1" class="headerlink" title="可配置的数据"></a>可配置的数据</h2><p>首先是数据的配置，这大概是最基础的，当我们在封装组件的时候，很多数据都是通过作用域内的变量来动态绑定的，例如 Vue 里面则是<code>data</code>、<code>props</code>、<code>computed</code>等维护 scope 内的数据绑定。</p>
<p>作为一个卡片，内容是从外面注入的，所以我们可以通过 <code>props</code> 来获取：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">template</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">h2</span>&gt;</span>&#123;&#123;model.question&#125;&#125;<span class="tag">&lt;/<span class="name">h2</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">div</span> <span class="attr">v-if</span>=<span class="string">"model.withImage"</span>&gt;</span><span class="tag">&lt;<span class="name">img</span> <span class="attr">:url</span>=<span class="string">"model.imageUrl"</span> /&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">div</span>&gt;</span>&#123;&#123;model.content&#125;&#125;<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">span</span> @<span class="attr">click</span>=<span class="string">"likeIt()"</span>&gt;</span>点赞<span class="tag">&lt;/<span class="name">span</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">span</span> @<span class="attr">click</span>=<span class="string">"keepIt()"</span>&gt;</span>收藏<span class="tag">&lt;/<span class="name">span</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">p</span> <span class="attr">v-for</span>=<span class="string">"comment in model.comments"</span>&gt;</span>&#123;&#123;comment&#125;&#125;<span class="tag">&lt;/<span class="name">p</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">template</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="javascript"></span></div><div class="line"><span class="keyword">export</span> <span class="keyword">default</span> &#123;</div><div class="line">  <span class="attr">name</span>: <span class="string">'my-card'</span>,</div><div class="line">  <span class="attr">props</span>: &#123; <span class="comment">// 传入数据</span></div><div class="line">    model: &#123;</div><div class="line">      <span class="attr">type</span>: <span class="built_in">Object</span>,</div><div class="line">      <span class="attr">default</span>: <span class="function"><span class="params">()</span> =&gt;</span> &#123;&#125;</div><div class="line">    &#125;</div><div class="line">  &#125;,</div><div class="line">  data() &#123;</div><div class="line">    <span class="keyword">return</span> &#123;</div><div class="line">      <span class="attr">isContextShown</span>: <span class="literal">false</span></div><div class="line">    &#125;;</div><div class="line">  &#125;,</div><div class="line">  <span class="attr">methods</span>: &#123;</div><div class="line">    likeIt() &#123;&#125;,</div><div class="line">    keepIt() &#123;&#125;</div><div class="line">  &#125;,</div><div class="line">  mounted() &#123;&#125;</div><div class="line">&#125;;</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div></pre></td></tr></table></figure>
<p>这里只展示简单的方式，我们会这样使用：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">my-card</span> <span class="attr">:model</span>=<span class="string">"cardModel"</span>&gt;</span><span class="tag">&lt;/<span class="name">my-card</span>&gt;</span></div></pre></td></tr></table></figure>
<h2 id="可配置的样式"><a href="#可配置的样式" class="headerlink" title="可配置的样式"></a>可配置的样式</h2><p>样式的配置，通常是通过<code>class</code>来实现的。其实这更多地是对样式的配置化设计，与我们的 HTML 和 Javascript 关系则比较少。</p>
<p>样式的配置，需要我们考虑 CSS 的设计，通常来说我们有两种方式：</p>
<ol>
<li>根据子元素匹配，来描述 CSS。</li>
<li>根据子 class 匹配，来描述 CSS。</li>
</ol>
<h3 id="根据子元素配置CSS"><a href="#根据子元素配置CSS" class="headerlink" title="根据子元素配置CSS"></a>根据子元素配置CSS</h3><p>这是以前比较常用的一种方式，简单地说，就是通过 CSS 匹配规则中的父子元素匹配，来完成我们的样式设计。</p>
<p>例如，我们有个模块：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"my-dialog"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">header</span>&gt;</span>I am header.<span class="tag">&lt;/<span class="name">header</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">section</span>&gt;</span></div><div class="line">    blablablabla...</div><div class="line">  <span class="tag">&lt;/<span class="name">section</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">footer</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">button</span>&gt;</span>Submit<span class="tag">&lt;/<span class="name">button</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">footer</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></td></tr></table></figure>
<p>样式则会这样设计：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.my-dialog</span> &#123;</div><div class="line">  <span class="attribute">background</span>: white;</div><div class="line">&#125;</div><div class="line"><span class="selector-class">.my-dialog</span> &gt; <span class="selector-tag">header</span> &#123;&#125;</div><div class="line"><span class="selector-class">.my-dialog</span> &gt; <span class="selector-tag">section</span> &#123;&#125;</div><div class="line"><span class="selector-class">.my-dialog</span> &gt; <span class="selector-tag">footer</span> &#123;&#125;</div></pre></td></tr></table></figure>
<p>或者说用 LESS 或是 SASS：</p>
<figure class="highlight less"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.my-dialog</span> &#123;</div><div class="line">  <span class="attribute">background</span>: white;</div><div class="line">  &gt; <span class="selector-tag">header</span> &#123;&#125;</div><div class="line">  &gt; <span class="selector-tag">section</span> &#123;&#125;</div><div class="line">  &gt; <span class="selector-tag">footer</span> &#123;&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>通过这种方式设计，或许我们在写代码的时候会稍微方便些，但是在维护上面很容易踩坑。曾经我也喜欢这种方式写，后来在一次次的 DOM 结构调整过程中，差点掉坑里出不来，于是乎后面慢慢改用第二种方式。</p>
<h3 id="根据子-class-配置CSS"><a href="#根据子-class-配置CSS" class="headerlink" title="根据子 class 配置CSS"></a>根据子 class 配置CSS</h3><p>其实相对于匹配简单的父子和后代元素关系，使用 class 来辅助匹配，则可以解决 DOM 调整的时候带来的问题。</p>
<p>这里我们使用 BEM 作为例子来解释下大概的想法吧：</p>
<p><strong>BEM</strong><br>BEM的意思就是块（block）、元素（element）、修饰符（modifier），是一种前端命名方法论。更多的大家可以去谷歌或者百度下。</p>
<p>简单说，我们写 CSS 的时候就是这样的：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.block</span>&#123;&#125;</div><div class="line"><span class="selector-class">.block__element</span>&#123;&#125;</div><div class="line"><span class="selector-class">.block--modifier</span>&#123;&#125;</div></pre></td></tr></table></figure>
<ul>
<li>block：可以与组件和模块对应的命名，如 card、dialog 等</li>
<li>element：元素，如 header、footer 等</li>
<li>modifier：修饰符，可视作状态等描述，如 actived、closed 等</li>
</ul>
<p>这样的话，我们上述的代码则会变成：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"my-dialog"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">header</span> <span class="attr">class</span>=<span class="string">"my-dialog__header"</span>&gt;</span>I am header.<span class="tag">&lt;/<span class="name">header</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">section</span> <span class="attr">class</span>=<span class="string">"my-dialog__section"</span>&gt;</span></div><div class="line">    blablablabla...</div><div class="line">  <span class="tag">&lt;/<span class="name">section</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">footer</span> <span class="attr">class</span>=<span class="string">"my-dialog__footer"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">"my-dialog__btn--inactived"</span>&gt;</span>Submit<span class="tag">&lt;/<span class="name">button</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">footer</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></td></tr></table></figure>
<p>搭配 LESS 的话，其实样式还是挺好写的：</p>
<figure class="highlight less"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.my-dialog</span> &#123;</div><div class="line">  <span class="attribute">background</span>: white;</div><div class="line">  <span class="selector-tag">&amp;</span><span class="selector-tag">__header</span> &#123;&#125;</div><div class="line">  <span class="selector-tag">&amp;</span><span class="selector-tag">__section</span> &#123;&#125;</div><div class="line">  <span class="selector-tag">&amp;</span><span class="selector-tag">__footer</span> &#123;&#125;</div><div class="line">  <span class="selector-tag">&amp;</span><span class="selector-tag">__btn</span> &#123;</div><div class="line">    <span class="selector-tag">&amp;</span><span class="selector-tag">--inactived</span></div><div class="line">  &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>Emmmmmm。。其实大家看了下，就发现这样的弊端了，这样我们在写 HTML 的时候，需要耗费很多的时间来写这些 class 名字，更惨的是，当我们需要切换某个元素状态的时候，判断条件会变得很长，像：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">button</span> <span class="attr">:class</span>=<span class="string">"isActived ? 'my-dialog__btn--actived' : 'my-dialog__btn--inactived'"</span>&gt;</span>Submit<span class="tag">&lt;/<span class="name">button</span>&gt;</span></div></pre></td></tr></table></figure>
<p>简直惨不忍睹。当然我们也可以把修饰符部分脱离，这样使用：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">"my-dialog__btn"</span> <span class="attr">:class</span>=<span class="string">"isActived ? 'actived' : 'inactived'"</span>&gt;</span>Submit<span class="tag">&lt;/<span class="name">button</span>&gt;</span></div></pre></td></tr></table></figure>
<p>这样会稍微好一些。BEM 的优势和弊端也都是很明显的，大家也可以根据具体的团队规模、项目规模、使用场景等，来决定要怎么设计。</p>
<p>当然，如今很多框架都支持样式的作用域，通常是通过在 class 里添加随机MD5等，来保持局部作用域的 class 样式。常见的话，我们是搭配第一和第二种方式一起使用的。</p>
<h2 id="可配置的展示"><a href="#可配置的展示" class="headerlink" title="可配置的展示"></a>可配置的展示</h2><p>可配置的展示，更多时候是指某些模块是否展示、展示的样式又是如何等。</p>
<p>例如，我们需要一个对话框，其头部、正文文字、底部按钮等功能都可支持配置：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"my-dialog"</span> <span class="attr">:class</span>=<span class="string">"&#123;'show': isShown&#125;"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">header</span> <span class="attr">v-if</span>=<span class="string">"model.title"</span>&gt;</span>&#123;&#123;model.title&#125;&#125;<span class="tag">&lt;/<span class="name">header</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">section</span> <span class="attr">v-if</span>=<span class="string">"model.content"</span>&gt;</span>&#123;&#123;model.content&#125;&#125;<span class="tag">&lt;/<span class="name">section</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">footer</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">button</span> <span class="attr">v-for</span>=<span class="string">"button in model.buttons"</span>&gt;</span>&#123;&#123;button.text&#125;&#125;<span class="tag">&lt;/<span class="name">button</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">footer</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></td></tr></table></figure>
<p>我们可以通过<code>model.title</code>来控制是否展示头部，可以通过<code>model.buttons</code>来控制底部按钮的数量和文字。</p>
<p>这只是最简单的实例，我们甚至可以通过配置，来控制出完全不一样的展示效果。搭配样式的配置，更是能让组件出神入化。当然，很多时候我们组件的封装是需要与业务设计相关，这样维护性能也会稍微好一些，这些前面也都有说到过。</p>
<h2 id="可配置的功能"><a href="#可配置的功能" class="headerlink" title="可配置的功能"></a>可配置的功能</h2><p>功能的配置，其实很多也与展示的配置相关。但是我们有些与业务相关的功能，则可以结合展示、功能来定义这样的配置。</p>
<p>举个例子，我们的这个卡片可以是视频、图片、文字的卡片：</p>
<ul>
<li>视频：点击播放</li>
<li>图片：点击新窗口查看</li>
<li>文字：点击无效果</li>
</ul>
<p>这种时候，我们可以两种方式：</p>
<ol>
<li>每个功能模块自己控制，同时通过配置控制哪个功能模块的展示。</li>
<li>模块展示会有些耦合，但在点击事件里，根据配置来进行不同的事件处理，获取不同的效果。</li>
</ol>
<p>对应维护性和可读性来说，第一种方式会获得更好的效果。如果问什么情况下会用到第二种，唔。。。大概是同样的呈现效果，在不同场景下的逻辑功能不一样时，使用比较方便吧。</p>
<p>功能配置化这块就不过多描述啦，毕竟这块需要与业务场景密切结合，大家更多地可以思考下，自己的项目中，是否可以有调整的空间，来使得整体的项目更好维护呢？</p>
<h1 id="结束语"><a href="#结束语" class="headerlink" title="结束语"></a>结束语</h1><hr>
<p>我们讲述了很多的配置化场景，也针对组件来详细描述了一些配置化的方向和方式。随着科技越来越发达，很多简单和重复性的事情我们可以交给机器去做，这就需要我们把相似的部分提取出来抽象封装，把可变的部分结合配置来高效地调整。<br>抽象封装和配置化的搭配，其实能获得很不错的效果，我们在对一些事物的认知上，也能进行更深层次的概括和思考。</p>
  
		
		<p style="margin-top:50px;">
			查看Github有更多内容噢：<a href="https://github.com/godbasin">https://github.com/godbasin</a>
			<br>
			更欢迎来<a href="https://godbasin.github.io/front-end-playground">被删的前端游乐场</a>边撸猫边学前端噢
		</p>
	</div>
	<img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/2code2.jpg" width="200" height="200" style="display:block;margin: 0 auto;" />
	<p style="text-align: center;margin-top: 10px;margin-bottom: 20px;">码生艰难，写文不易，给我家猪囤点猫粮了喵~</p>
	<div class="author-right">
  		<p>作者：被删</p>
  		<p>出处：<a href="https://godbasin.github.io">https://godbasin.github.io</a></p>
  		<p>本文版权归作者所有，欢迎转载，但未经作者同意必须保留此段声明，且在文章页面明显位置给出原文连接，否则保留追究法律责任的权利。</p>
	</div>
		<footer class="article-footer clearfix">

  <div class="article-tags">
  
  <span></span> <a href="/tags/分享/">分享</a>
  </div>


<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/categories/思想棉花糖/">思想棉花糖</a>
</div>



<div class="article-share" id="share">

  
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style_24x24">
	<a class="jiathis_button_qzone"></a>
	<a class="jiathis_button_tsina"></a>
	<a class="jiathis_button_tqq"></a>
	<a class="jiathis_button_weixin"></a>
	<a class="jiathis_button_renren"></a>
	<a href="http://www.jiathis.com/share?uid=2134021" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
</div>
<script type="text/javascript">
var jiathis_config = {data_track_clickback:'true'};
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js?uid=2134021" charset="utf-8"></script>
<!-- JiaThis Button END -->   


</div>
</footer>   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2018/06/17/component-communication-with-data-model/" title="数据抽离与数据管理">
  <strong>PREVIOUS:</strong><br/>
  <span>
  数据抽离与数据管理</span>
</a>
</div>


<div class="next">
<a href="/2018/06/02/component-with-itself/"  title="一个组件的自我修养">
 <strong>NEXT:</strong><br/> 
 <span>一个组件的自我修养
</span>
</a>
</div>

</nav>

	<!-- 如果不是首页且没使用 `comments: false` 关闭评论，则尝试加载评论 -->

    <!-- 配置中启用多说时，导入相应代码 -->
    


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
  <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#配置化思想"><span class="toc-number">1.</span> <span class="toc-text">配置化思想</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的数据"><span class="toc-number">1.1.</span> <span class="toc-text">可配置的数据</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#应用中的可配置数据"><span class="toc-number">1.1.1.</span> <span class="toc-text">应用中的可配置数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#代码中的可配置数据"><span class="toc-number">1.1.2.</span> <span class="toc-text">代码中的可配置数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#文件里的可配置数据"><span class="toc-number">1.1.3.</span> <span class="toc-text">文件里的可配置数据</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的接口"><span class="toc-number">1.2.</span> <span class="toc-text">可配置的接口</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的页面"><span class="toc-number">1.3.</span> <span class="toc-text">可配置的页面</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的应用"><span class="toc-number">1.4.</span> <span class="toc-text">可配置的应用</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#组件配置化"><span class="toc-number">2.</span> <span class="toc-text">组件配置化</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的数据-1"><span class="toc-number">2.1.</span> <span class="toc-text">可配置的数据</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的样式"><span class="toc-number">2.2.</span> <span class="toc-text">可配置的样式</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#根据子元素配置CSS"><span class="toc-number">2.2.1.</span> <span class="toc-text">根据子元素配置CSS</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#根据子-class-配置CSS"><span class="toc-number">2.2.2.</span> <span class="toc-text">根据子 class 配置CSS</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的展示"><span class="toc-number">2.3.</span> <span class="toc-text">可配置的展示</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#可配置的功能"><span class="toc-number">2.4.</span> <span class="toc-text">可配置的功能</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#结束语"><span class="toc-number">3.</span> <span class="toc-text">结束语</span></a></li></ol>
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  	
	<div class="archiveslist">
		<p class="asidetitle">最近文章</p>
			<ul class="archive-list">
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/15/wxapp-latest-20191115/" title="小程序开发月刊第11期（20191115）">小程序开发月刊第11期（201911...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/10/change-log/" title="前端 CHANGELOG 生成指南">前端 CHANGELOG 生成指南...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/09/wxapp-global-data-behavior/" title="小程序的奇技淫巧 -- globalDataBehavior管理全局状态">小程序的奇技淫巧 -- global...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/15/wxapp-latest-20191015/" title="小程序开发月刊第十期（20191015）">小程序开发月刊第十期（2019101...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/13/about-front-end-3-growth/" title="前端这几年--3.关于成长和焦虑">前端这几年--3.关于成长和焦虑...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/09/16/wxapp-latest-20190916/" title="小程序开发月刊第九期（20190916）">小程序开发月刊第九期（2019091...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/08/15/wxapp-latest-20190815/" title="小程序开发月刊第八期（20190815）">小程序开发月刊第八期（2019081...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/27/front-end-playground/" title="被删的前端游乐场建成！">被删的前端游乐场建成！</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/21/vue-for-everyone-3/" title="9102全员学Vue--3.把页面拼成个Web应用">9102全员学Vue--3.把页面拼...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/15/wxapp-latest-20190715/" title="小程序开发月刊第七期（20190715）">小程序开发月刊第七期（2019071...</a>
				</li>
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
			</ul>
	</div>


  
  <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">归档</a></p>
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">十一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">十月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">九月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">八月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">七月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">六月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">五月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">四月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">三月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">二月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">十二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">十一月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">十月 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">九月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/08/">八月 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/07/">七月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/06/">六月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/05/">五月 2018</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">四月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">三月 2018</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/">一月 2018</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/">十二月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/">十一月 2017</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/">十月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/">九月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/">八月 2017</a><span class="archive-list-count">11</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/07/">七月 2017</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/06/">六月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">五月 2017</a><span class="archive-list-count">15</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">四月 2017</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">三月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/02/">二月 2017</a><span class="archive-list-count">41</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/">一月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/">十二月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/">十一月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a><span class="archive-list-count">14</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a><span class="archive-list-count">9</span></li></ul>
  </div>


  
<div class="archiveslist">
	<p class="asidetitle"><a href="/categories">分类</a></p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/CSS炒饭/" title="CSS炒饭">CSS炒饭<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/D3小馒头/" title="D3小馒头">D3小馒头<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular2火锅/" title="angular2火锅">angular2火锅<sup>25</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular混搭/" title="angular混搭">angular混搭<sup>33</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/box2djs方糖/" title="box2djs方糖">box2djs方糖<sup>34</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/cyclejs哈根达斯/" title="cyclejs哈根达斯">cyclejs哈根达斯<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/jQuery杂烩/" title="jQuery杂烩">jQuery杂烩<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/js什锦/" title="js什锦">js什锦<sup>26</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/react沙拉/" title="react沙拉">react沙拉<sup>16</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/three-js奶茶/" title="three.js奶茶">three.js奶茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/vue八宝粥/" title="vue八宝粥">vue八宝粥<sup>29</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/webpack宾治/" title="webpack宾治">webpack宾治<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/web乱炖/" title="web乱炖">web乱炖<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/前端满汉全席/" title="前端满汉全席">前端满汉全席<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/喵/" title="喵">喵<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/小程序双皮奶/" title="小程序双皮奶">小程序双皮奶<sup>27</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/工作这杯茶/" title="工作这杯茶">工作这杯茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/应用巧克力盒/" title="应用巧克力盒">应用巧克力盒<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/思想棉花糖/" title="思想棉花糖">思想棉花糖<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/柴米油盐工具集/" title="柴米油盐工具集">柴米油盐工具集<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/自动化甜筒/" title="自动化甜筒">自动化甜筒<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/非前端钙片/" title="非前端钙片">非前端钙片<sup>7</sup></a>
			</li>
		
		</ul>
</div>


  
<div class="archiveslist">
	<p class="asidetitle">标签</p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/分享/" title="分享">分享<sup>44</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/原创部件/" title="原创部件">原创部件<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/心态/" title="心态">心态<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/教程/" title="教程">教程<sup>73</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/晒猫/" title="晒猫">晒猫<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/笔记/" title="笔记">笔记<sup>121</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/算法/" title="算法">算法<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/自制插件/" title="自制插件">自制插件<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/逻辑实现/" title="逻辑实现">逻辑实现<sup>5</sup></a>
			</li>
		
		</ul>
</div>


    <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">about</a></p>
      <ul class="archive-list">
      	<li class="archive-list-item">
      		<a>wangbeishan@163.com</a>
      		<a href="https://github.com/godbasin">github.com/godbasin</a>
      	</li>
      </ul>
  </div>

  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a>
</div>

</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<section class="info">
		<p> 即使梦想再小，却很伟大 ^_^ </p>
	</section>
	 
		<p class="copyright">Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/A-limon/pacman" target="_blank" title="Pacman">Pacman</a> © 2019 
		
		<a href="https://godbasin.github.io" target="_blank" title="被删">被删</a>
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else
    {
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      h  = $('article h2')
      ah = $('article h2'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  if(ah.length==0){
    t.css('display','none');
  }else{
    c.click(function(){
      ta.css('display', 'block').addClass('fadeIn');
    });
    o.click(function(){
      ta.css('display', 'none');
    });
    $(window).scroll(function(){
      ta.css("top",Math.max(140,320-$(this).scrollTop()));
    });
  };
});
</script>







  </body>
</html>
